<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http:www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<include file="./Home/Tpl/Admin/Common/cssjs.html" />
</head>
<body>
<div class="subnav">
  <div class="content-menu ib-a blue line-x"> <a href='{:U("Attachments/index")}' class="on"><em>附件管理</em></a></div>
</div>
<style type="text/css">
	html{_overflow-y:scroll}
</style>
<script type="text/javascript" src="{$Config.siteurl}statics/js/jquery.sgallery.js"></script>
<div class="pad-lr-10">
  <form name="searchform" action="{:U("Attachments/index")}" method="get" >
    <input type="hidden" value="Attachment" name="g">
    <input type="hidden" value="Attachments" name="m">
    <input type="hidden" value="index" name="a">
    <table width="100%" cellspacing="0" class="search-form">
      <tbody>
        <tr>
          <td><div class="explain-col">名称
              <input type="text" value="{$filename}" class="input-text" name="filename">
              上传时间
              <link rel="stylesheet" type="text/css" href="{$Config.siteurl}statics/js/calendar/jscal2.css"/>
              <link rel="stylesheet" type="text/css" href="{$Config.siteurl}statics/js/calendar/border-radius.css"/>
              <link rel="stylesheet" type="text/css" href="{$Config.siteurl}statics/js/calendar/win2k.css"/>
              <script type="text/javascript" src="{$Config.siteurl}statics/js/calendar/calendar.js"></script> 
              <script type="text/javascript" src="{$Config.siteurl}statics/js/calendar/lang/en.js"></script>
              <input type="text" name="start_uploadtime" id="start_uploadtime" value="{$start_uploadtime}" size="21" class="date" readonly>
              &nbsp;<script type="text/javascript">
			Calendar.setup({
			weekNumbers: true,
		    inputField : "start_uploadtime",
		    trigger    : "start_uploadtime",
		    dateFormat: "%Y-%m-%d %H:%M:%S",
		    showTime: true,
		    minuteStep: 1,
		    onSelect   : function() {this.hide();}
			});
        </script>至
              <input type="text" name="end_uploadtime" id="end_uploadtime" value="{$end_uploadtime}" size="21" class="date" readonly>
              &nbsp;<script type="text/javascript">
			Calendar.setup({
			weekNumbers: true,
		    inputField : "end_uploadtime",
		    trigger    : "end_uploadtime",
		    dateFormat: "%Y-%m-%d",
		    showTime: false,
		    minuteStep: 1,
		    onSelect   : function() {this.hide();}
			});
        </script> 附件类型
              <input type="text" value="{$fileext}" class="input-text" name="fileext">
              <input type="submit" value="搜索" class="button" name="dosubmit">
          </div></td>
        </tr>
      </tbody>
    </table>
  </form>
  <div class="table-list">
  <form name="myform" action="{:U("Attachments/delete")}" method="post" id="myform">
    <table width="100%" cellspacing="0">
      <thead>
        <tr>
          <th width="10%">删除</th>
          <th width="5%">ID</th>
          <th width="8%" >模块名称 </th>
          <th width="8%" >栏目名称</th>
          <th width="20%">附件名称
            <div class="tab-use">
              <div style="position:relative">
                <div class="arrows cu" onmouseover="hoverUse('use-div');" onmouseout="hoverUse();" onmouseover="this.style.display='block'"></div>
              </div>
              <ul id="use-div" class="tab-web-panel" onMouseOver="this.style.display='block'"  onmouseout="hoverUse('use-div');">
                <li><a href="{:U("Attachments/index",array_merge($_GET,array("status"=>"0")))}">未使用</a></li>
                <li><a href="{:U("Attachments/index",array_merge($_GET,array("status"=>"1")))}">已使用</a></li>
              </ul>
            </div>
        </th>
        <th width="10%" >附件大小</th>
        <th width="20%" >上传时间</th>
        <th width="15%" >管理操作</th>
      </tr>
      </thead>
      <tbody>
      <volist name="data" id="vo">
        <tr>
          <td width="10%" align="center"><input type="checkbox" name="aid[]" value="{$vo.aid}" id="att_{$vo.aid}" /></td>
          <td width="5%"  align="center">{$vo.aid}</td>
          <td width="8%" align="center">{$vo.module}</td>
          <td width="8%"  align="center">{$category[$vo['catid']]['catname']}</td>
          <td width="20%"><img src="{$Config.siteurl}statics/images/ext/{$vo.fileext}.gif" />{$vo.filename} 
          <if condition=" $vo['thumb'] ">
          <img title="管理缩略图" src="{$Config.siteurl}statics/images/admin_img/havthumb.png" onClick="showthumb({$vo.aid}, '{$vo.filename}')"/>
          </if>
          <if condition=" $vo['status'] ">
          <img title="管理缩略图" src="{$Config.siteurl}statics/images/admin_img/link.png"/>
          </if>
          </td>
          <td width="10%" align="center">{$vo.filesize} KB</td>
          <td width="12%"  align="center">{$vo.uploadtime}</td>
          <td  align="center"><a href="javascript:preview({$vo.aid}, '{$vo.filename}','<?=CONFIG_SITEFILEURL;?>{$vo.filepath}')">预览</a> | <a href="javascript:;" onClick="att_delete(this,'{$vo.aid}')">删除</a></td>
        </tr>
      </volist>
      </tbody>
    </table>
    <div id="pages">{$Page}</div>
    <div class="btn"><a onClick="javascript:$('input[type=checkbox]').attr('checked', true)">全选</a>/<a onClick="javascript:$('input[type=checkbox]').attr('checked', false)">取消</a>
      <input type="submit" class="button" name="dosubmit" value="删除" onClick="document.myform.action='{:U("Attachments/delete")}';return confirm('确认删除吗？')"/>
    </div>
  </form>
</div>
</div>
<script type="text/javascript" src="{$Config.siteurl}statics/js/imgready.js"></script>
<script type="text/javascript">
<!--
window.top.$('#display_center_id').css('display', 'none');
function preview(id, name, filepath) {
    if (IsImg(filepath)) {
        imgReady(filepath, function () {
            var width = 0,
			    maxWidth = 500,
				maxHeight = 500,
                height = 0;
            var hRatio;
            var wRatio;
            var Ratio = 1;
            var w = this.height;
            var h = this.width;
            wRatio = 500 / this.height;
            hRatio = 500 / this.width;
			
            if (maxWidth == 0) { //
                if (hRatio < 1) Ratio = hRatio;
            } else if (maxHeight == 0) {
                if (wRatio < 1) Ratio = wRatio;
            } else if (wRatio < 1 || hRatio < 1) {
                Ratio = (wRatio <= hRatio ? wRatio : hRatio);
            }
            if (Ratio < 1) {
                w = w * Ratio;
                h = h * Ratio;
            }
            width = h;
            height = w;

            art.dialog.through({
                title: '预览',
                width: width,
                height: height,
                content: '<img src="' + filepath + '"  width="' + width + '" height="' + height + '" />',
                lock: true
            });
        });
    } else {
        art.dialog.through({
            title: '预览',
            padding: 0,
			width: 230,
			height:150,
            content: '<a href="' + filepath + '" target="_blank"><img src="{$Config.siteurl}statics/images/admin_img/down.gif">单击打开</a>',
            lock: true
        });
    }
}

function att_delete(obj, aid) {
    art.dialog.through({
        content: '确认删除吗？',
        lock: true,
        style: 'confirm',
        id: 'att_delete'
    }, function () {
        $.get('?a=delete&m=Attachments&g=Attachment&aid=' + aid + '&pc_hash=nbldbN', function (data) {
            if (data.status == true){
				$(obj).parent().parent().fadeOut("slow");
			}else{
				art.dialog.alert(data.info);
			}
        },"json")

    }, function () {});
};

function showthumb(id, name) {
	art.dialog.open('index.php?a=pullic_showthumbs&m=Attachments&g=Attachment&aid=' + id,{
		title: '管理缩略图--' + name,
		id: 'edit',
		width: '500px',
		height: '400px'
	});
}

function hoverUse(target) {
    if ($("#" + target).css("display") == "none") {
        $("#" + target).show();
    } else {
        $("#" + target).hide();
    }
}

function IsImg(url) {
    var sTemp;
    var b = false;
    var opt = "jpg|gif|png|bmp|jpeg";
    var s = opt.toUpperCase().split("|");
    for (var i = 0; i < s.length; i++) {
        sTemp = url.substr(url.length - s[i].length - 1);
        sTemp = sTemp.toUpperCase();
        s[i] = "." + s[i];
        if (s[i] == sTemp) {
            b = true;
            break;
        }
    }
    return b;
}

function AutoResizeImage(maxWidth, maxHeight, Width ,Height) {
    var img = new Image();
    img.src = objImg.src;
    var hRatio;
    var wRatio;
    var Ratio = 1;
    var w = Width;
    var h = Height;
    wRatio = maxWidth / w;
    hRatio = maxHeight / h;
    if (maxWidth == 0 && maxHeight == 0) {
        Ratio = 1;
    } else if (maxWidth == 0) { //
        if (hRatio < 1) Ratio = hRatio;
    } else if (maxHeight == 0) {
        if (wRatio < 1) Ratio = wRatio;
    } else if (wRatio < 1 || hRatio < 1) {
        Ratio = (wRatio <= hRatio ? wRatio : hRatio);
    }
    if (Ratio < 1) {
        w = w * Ratio;
        h = h * Ratio;
    }
    objImg.height = h;
    objImg.width = w;
}
//-->
</script>
</body>
</html>